package org.fullhappy;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class GenerateBusinessObjects
 */
@WebServlet(name = "GenerateBusinessObjects", urlPatterns = {"/GenerateBusinessObjects"})
public class GenerateBusinessObjects extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GenerateBusinessObjects() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ObjectInputStream resultStream = null;  
		ObjectOutputStream sendStream = null;  
		List results = null;  
		try {  
		resultStream = new ObjectInputStream(request.getInputStream());  
		results = (List) resultStream.readObject();  
		resultStream.close();  
		sendStream = new ObjectOutputStream(response.getOutputStream());  
		sendStream.writeObject(String.valueOf(results.size()));  
		sendStream.flush();  
		sendStream.close();  
		} catch (IOException e) {  
		e.printStackTrace();   
		} catch (ClassNotFoundException e) {  
		e.printStackTrace();  
		}  
	}

}
